<!-- 添加 联代/竞品 历史添加选择弹窗 -->
<template>
  <dt-modal-info ref='edit' :title='title' :label-width='130' :width='550'>
    <div class="add_history">
      <Row class="label_warp">
        <Col span="24" class="tips">
        <Icon type="md-alert" class="tips_icon" />
        <div>{{info.topTips}}</div>
        </Col>
      </Row>
      <div class="list_title">{{this.info.labelTxt}}名称</div>
      <ul class="sourcedataCon">
        <li v-for="(item, index) in infoList" :key="index">
          <label>{{ item.generationName }}</label>
          <div class="add_item" @click='creatAdd(item)'>
            添加至日报
          </div>
        </li>
      </ul>
      <div @click="creatAdd(null)" class="add_btn">
        <Icon type="md-add-circle" /> 新建1个{{this.info.labelTxt}}
      </div>
    </div>
  </dt-modal-info>
</template>

<script>
  import dailyApi from '@/biz/buildingHome/daily'

  export default {
    data() {
      return {
        info: {},
        infoList: [],
        title: ''
      }
    },
    methods: {
      show(data) {
        this.info = data
        this.title = `添加${data.labelTxt}`
        this.$refs.edit.show()
        // this.getData()
      },
      creatAdd(data) {
        console.log(data)
        let obj = {}
        if (data) {
          data.arrivePeople = 0
          data.clinchDeal = 0
          obj = data
        } else {
          obj = {
            generationName: '',
            arrivePeople: 0,
            clinchDeal: 0,
            disabledFlag: false
          }
        }
        this.$emit('success', obj)
        this.$refs.edit.hide()
      },
      getData(data) {
        console.log(data, '已展示数据Id')
        return new Promise((resolve, reject) => {
          let params = {
            buildingId: this.$dt.buildInfo().housesId,
            generationIds: data.ids,
            date: data.date,
            projectType: data.type,
          }
          dailyApi.findDailyGenerationHistory(params).then((res) => {
            this.infoList = res
            resolve(res)
          })
        })
      }
    }
  }
</script>
<style lang='scss' scoped>
  .add_history {
    .list_title {
      border-bottom: 1px solid #ccc;
      line-height: 32px;
      font-size: 16px;
    }

    .sourcedataCon {
      max-height: 400px;
      min-height: 250px;
      overflow-y: auto;
      padding: 10px 0;

      li {
        margin: 0;
        line-height: normal;
        padding: 7px 10px;
        clear: both;
        color: #515a6e;
        font-size: 14px !important;
        white-space: nowrap;
        list-style: none;
        display: flex;
        justify-content: space-between;

        label {
          margin: 0 4px;
          cursor: pointer;
          min-width: 120px;
        }
      }
    }

    .label_warp {
      margin-bottom: 15px;
      background-color: rgba(254, 252, 236, 1);
      width: auto;
      line-height: 32px;
      padding: 10px;

      .tips {
        line-height: 20px;
        font-size: 14px;
        display: flex;

        .tips_icon {
          font-size: 20px;
          color: #0f42a7;
          vertical-align: sub;
        }
      }
    }

    .add_btn {
      color: #2b85e4;
      font-weight: normal;
      font-size: 14px;
      cursor: pointer;
      padding-top: 10px;
      border-top: 1px solid #ccc;
    }

    .add_item {
      color: #2d8cf0;
      cursor: pointer;
    }
  }
</style>